package com.example.film.mapper;

import com.example.film.entity.FilmSchedule;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.sql.Date;
import java.util.List;

@Mapper
public interface FilmScheduleMapper {
    //电影排片table-->filmschedule
    //查看排片信息
    @Select("select rank,filmName,showDays,type,totalSession,totalCircle,amSession,amCircle,\n" +
            "pmSession,pmCircle,goldSession,goldCircle,addSession,addCircle,currentDate from filmschedule")
    List<FilmSchedule> findFilmSchedule();

    //分页查看排片信息
    @Select("select rank,filmName,showDays,type,totalSession,totalCircle,amSession,amCircle,\n" +
            "pmSession,pmCircle,goldSession,goldCircle,addSession,addCircle,currentDate from filmschedule LIMIT #{pageSize} OFFSET #{startIndex}")
    List<FilmSchedule> findFilmScheduleInfo(@Param("startIndex") Integer startIndex, @Param("pageSize") Integer pageSize);

    //根据日期查看电影排片信息
    @Select("select rank,filmName,showDays,type,totalSession,totalCircle,amSession,amCircle,\n" +
            "pmSession,pmCircle,goldSession,goldCircle,addSession,addCircle,currentDate from filmschedule where currentdate=#{date}")
    List<FilmSchedule> findFilmScheduleByDate(Date date);

    //根据日期查看每日总排片前十电影排片信息
    @Select("select filmName,totalsession,amsession,pmsession,goldsession,addsession,currentdate from filmschedule\n" +
            "where currentdate=#{date} limit 10")
    List<FilmSchedule> findScheduleInfoByDate(Date date);

    //影片排片统计信息
    @Select("select filmname, sumSession from filmsumsession")
    List<FilmSchedule> findFilmSumSession();

    //影片类型排片统计信息
    @Select("select type, sumSession from typesumsession")
    List<FilmSchedule> findTypeSumSession();
}
